/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package grafrajz.dialogs;

import grafrajz.GrafRajzWindow;
import grafrajz.GraphLogic;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JPanel;

/**
 *
 * @author adam_fejes_dell
 * Új gráf létrehozó párbeszédablak
 */
public class NewGraphWindow extends JDialog{
    
    private JCheckBox isWeightened, isDirected, isTree;
    private JPanel buttonsPanel;
    private JButton okBtn, cancelBtn;

    public NewGraphWindow(final GrafRajzWindow frame, final GraphLogic gLogic) {
        super(frame);
        
        setTitle("Create new graph");
        setLayout(new GridLayout(4, 1));
        
        setLocationRelativeTo(frame);
        setSize(new Dimension(300, 300));
        
        isWeightened = new JCheckBox("Súlyozottság");
        add(isWeightened);
        
        isDirected = new JCheckBox("Irányítottság");
        add(isDirected);
        
        isTree = new JCheckBox("Fa-e?");
        add(isTree);
        
        buttonsPanel = new JPanel(new BorderLayout());
        add(buttonsPanel);
        
        okBtn = new JButton("OK");
        okBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                gLogic.newGraph(isWeightened.isSelected(), isDirected.isSelected(), isTree.isSelected());
                frame.updateWindow(frame);
                dispose();
            }
        });
        buttonsPanel.add(okBtn, BorderLayout.WEST);
        
        
        cancelBtn = new JButton("Cancel");
        cancelBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
        buttonsPanel.add(cancelBtn, BorderLayout.EAST);
        add(buttonsPanel);
        
    }
    
    
    
}
